define([ 'jquery'], function( $){
    require('../../common/commontools.less');
    return {
        dom:null,
        showMsgDialog:function(content,leftcallback,rightcallback){
            var msgDom = [
                '<div class="dialogwrap">',
                '<div  class="dialoginnerwrap">',
                '<div class="dialogcontent">'+content+'</div>',
                '<div class="msg-dialogbuttonwrap"><div id="dialog-right">确定</div></div>',
                '</div>',
                '</div>'
            ].join('');
            this.dom=$(msgDom);
            $('body').append(this.dom);
            this.dom.find('#dialog-left').click(function(){
                this.dom.remove();
                leftcallback&&leftcallback();
            }.bind(this));
            this.dom.find('#dialog-right').click(function(){
                this.dom.remove();
                rightcallback&&rightcallback();
            }.bind(this));
        },
        oppConfirm: function(content,leftcallback,rightcallback,tips){
            var msgDom = [
                '<div class="dialogwrap">',
                '<div class="confirm-popup">',
                '<div class="confirm-content">'+ content +'</div>',
                '<div class="confirm-tips">'+ tips +'</div>',
                '<div class="confirm-button"><div id="button-left">取消</div><div class="button-sure" id="button-right">确定</div></div>',
                '</div>',
                '</div>'
            ].join('');
            this.dom = $(msgDom);
            if(!tips){
                this.dom.find('.confirm-tips').hide();
            }
            $('body').append(this.dom);
            this.dom.find('#button-left').click(function(){
                this.dom.remove();
                leftcallback&&leftcallback();
            }.bind(this));
            this.dom.find('#button-right').click(function(){
                this.dom.remove();
                rightcallback&&rightcallback();
            }.bind(this));

        },
        confirm: function(content,leftcallback,rightcallback,tips,option){
            var msgDom = [
                '<div class="dialogwrap">',
                '<div class="confirm-popup">',
                '<div class="confirm-content">'+ content +'</div>',
                '<div class="confirm-tips">'+ tips +'</div>',
                '<div class="confirm-button"><div class="button-sure" id="button-left">确定</div><div id="button-right">取消</div></div>',
                '</div>',
                '</div>'
            ].join('');
            this.dom = $(msgDom);
            if(option){
                this.dom.find('.confirm-popup').css("background-color",option.backgroundColor);

            }
            if(!tips){
                this.dom.find('.confirm-tips').hide();
            }
            $('body').append(this.dom);
            this.dom.find('#button-left').click(function(){
                this.dom.remove();
                leftcallback&&leftcallback();
            }.bind(this));
            this.dom.find('#button-right').click(function(){
                this.dom.remove();
                rightcallback&&rightcallback();
            }.bind(this));

        },
        showDialog:function(content,leftcallback,rightcallback){
            var msgDom = [
                '<div class="dialogwrap">',
                '<div  class="dialoginnerwrap">',
                '<div class="dialogcontent">'+content+'</div>',
                '<div class="dialogbuttonwrap"><div id="dialog-left">取消</div><div id="dialog-right">确定</div></div>',
                '</div>',
                '</div>'
            ].join('');
            this.dom=$(msgDom);
            $('body').append(this.dom);
            this.dom.find('#dialog-left').click(function(){
                this.dom.remove();
                leftcallback&&leftcallback();
            }.bind(this));
            this.dom.find('#dialog-right').click(function(){
                this.dom.remove();
                rightcallback&&rightcallback();
            }.bind(this));
        },
        msgDialog : function(status, content, time, callback){
            var icon = status ? 'icon-adopt' : 'icon-no';
            var msgDom = [
                '<div class="msgDialogWrap">',
                '<div class="msgDialogMask"></div>',
                '<div class="msgDialogIcon '+ icon +'"></div>',
                '<div class="msgDialogTitle">' + content + '</div>',
                '</div>'
            ].join(''), $msgDom = $(msgDom);

            $('body').append($msgDom);

            if(time){
                setTimeout(function(){
                    $msgDom.remove();
                    (callback && typeof(callback) === "function") && callback();
                }, time );
            }else{
                (callback && typeof(callback) === "function") && callback();
            }
        },
        breakToast : function(contenttop, contentbottom,time, callback){
            var toastDom = [
                '<div class="toastBreakWrap">',
                '<div class="toastBreak">',
                '<div class="toastTop">' + contenttop + '</div>',
                '<div class="toastBottom">' + contentbottom + '</div>',
                '</div>',
                '</div>'
            ].join(''), $toastDom = $(toastDom);

            $('body').append($toastDom);

            if(time){
                setTimeout(function(){
                    $toastDom.remove();
                    (callback && typeof(callback) === "function") && callback();
                }, time );
            }else{
                (callback && typeof(callback) === "function") && callback();
            }
        },
        Toast: function(content, time, callback){
            if(!time) time = 1000;
            var toastDom = [
                '<div class="toastWrap">',
                '<div class="toastTitle">' + content + '</div>',
                '</div>'
            ].join(''), $toastDom = $(toastDom);

            $('body').append($toastDom);

            if(time){
                setTimeout(function(){
                    $toastDom.remove();
                    (callback && typeof(callback) === "function") && callback();
                }, time );
            }else{
                (callback && typeof(callback) === "function") && callback();
            }
        },


    }

});
